package cn.oa.dao;

import cn.oa.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.junit.Test;

import java.sql.SQLException;

public class AttendanceText {
    SqlSessionFactory sqlSessionFactory = MybatisUtil.sessionFactory;
    SqlSession sqlSession = sqlSessionFactory.openSession();
    @Test
    public void deleteAttendanceByEmployeeId() throws SQLException {
        //读取文件
//        SqlSession sqlSession= MybatisUtil.getSqlSession();
        int ret=sqlSession.getMapper(AttendanceDao.class).deleteAttendanceByEmployeeId(1);
        //提交事务
        sqlSession.commit();
        System.out.println(ret>0?"删除成功":"删除失败");
        //关闭
        sqlSession.close();
    }

    @Test
    public void  addSinginByEmployeeId() throws SQLException {
        SqlSession sqlSession=null;
        try {
            int r=sqlSession.getMapper(AttendanceDao.class).deleteAttendanceByEmployeeId(9);
            System.out.println(r);
            sqlSession.commit();
        } catch (Exception e) {
            sqlSession.rollback();
            e.printStackTrace();
        } finally {
            sqlSession.close();
        }
    }
    @Test
    public void aaa(){
        SqlSession sqlSession=null;
        try {
            int r=sqlSession.getMapper(AttendanceDao.class).addSinginByEmployeeId(9);
            System.out.println(r);
            sqlSession.commit();
        } catch (Exception e) {
            sqlSession.rollback();
            e.printStackTrace();
        } finally {
            sqlSession.close();
        }
    }
    @Test
    public void dfa(){
        SqlSession sqlSession=null;
        try {
            int r=sqlSession.getMapper(AttendanceDao.class).addSinginByEmployeeId(1);
            System.out.println(r>0?"h":"a");
            sqlSession.commit();
        } catch (Exception e) {
            sqlSession.rollback();
            e.printStackTrace();
        } finally {
            sqlSession.close();
        }
    }

}
